define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'lists/shenhes/index' + location.search,
                    add_url: 'lists/shenhes/add',
                    // edit_url: 'lists/shenhes/edit',
                    // del_url: 'lists/shenhes/del',
                    multi_url: 'lists/shenhes/multi',
                    import_url: 'lists/shenhes/import',
                    table: 'list_one',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                search:false,
                columns: [
                    [
                        // {checkbox: true},
                        // {field: 'id', title: __('Id'), operate: false},
                        {field: 'tong_storage', title: __('暂存单号'), operate: 'LIKE', table: table, class: 'autocontent', formatter: function(value, row, index) {
                                if(value){
                                    return value;
                                }else{
                                    return '-';
                                }
                            }},
                        {field: 'tong_number', title: __('服务单号'), operate: false, table: table, class: 'autocontent',formatter: function(value, row, index) {
                                if(value){
                                    return value;
                                }else{
                                    return '-';
                                }
                            }
                        },
                        {field: 'main_free', title: __('应缴服务费'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'car_num', title: __('车牌号'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'car_vin', title: __('车架号'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        // {field: 'ginseng_name', title: __('参统人'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'learned_name', title: __('被服务人'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'yw_hetong_time', title: __('Yw_hetong_time'), operate: false, addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
                        {field: 'plan_strattime', title: __('服务起期'), operate: false, addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
                        {field: 'yw_hetongpeo', title: __('审核人'), operate: false, table: table, class: 'autocontent', formatter: function(value, row, index) {
                                if(value){
                                    return value;
                                }else{
                                    return '-';
                                }
                            }
                        },
                        {field: 'status', title: __('状态'), searchList: {
                                "0": __('暂存'),
                                "1": __('待审核'),
                                "2": __('待市级审核'),
                                "3": __('审核通过待缴费'),
                                "4": __('待修改'),
                                "5": __('已出单'),
                            },custom: {0:'success', 1:'danger',2:'warning', 3:'info', 4:'default', 5:'primary', 6:'huang', 7:'zi'},  formatter: Table.api.formatter.label, operate: false
                        },
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate,
                            buttons: [
                                {
                                    name: 'details',
                                    text: __('去审核'), // 按钮文字，语言在对应的lang文件设置
                                    title: __('去审核'), // 提示
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: '', // 更换图标
                                    url:'lists/shenhes/details',
                                    extend: 'data-area=["100%","100%"]',
                                }
                            ]
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        details: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },

        }
    };
    return Controller;
});
